#!/usr/bin/env python
# -*- coding: UTF-8 -*-
'''
@Project ：saas 
@File    ：account.py
@IDE     ：PyCharm 
@Author  ：janggui
@Date    ：2022/12/15 14:10 
'''

from django.shortcuts import render, HttpResponse
from web.forms.account import RegisterForm, SendSmsForm
from django.http import JsonResponse

"""返回注册页面"""
def register(request):
    form = RegisterForm()

    return render(request, 'web/register.html', {'form': form})


"""发松短信一次"""


def send_sms(request):

    form = SendSmsForm(request, data=request.GET)
    if form.is_valid():
        # 验证通过发短信，写redis
        return JsonResponse({'status': True})
    #  发送失败返回错误信息
    return JsonResponse({'status': False, 'error': form.errors})

